// 根据老的state和action返回新的state
// 导入状态常量
import {INCREMENT,DECREMENT} from './action-types';

// 导入combineReducers方法合并reducer
import {combineReducers} from 'redux';


function count(state=10,action){
    console.log('reducer',state,action.data)
    switch(action.type){
        case INCREMENT:
            return state+action.data;
        case DECREMENT:
            return state-action.data;
        default:
            return state;
    }
}
// 用户状态信息
const initUser={name:'zp',gender:'女'} 
function user(state=initUser,action){
    console.log('reducer',state,action.data)
    switch(action.type){
        default:
            return state;
    }
}

// 合并reducer并导出一个reducer对象; 接收包含所有reducer函数组成的对象, 返回一个reducers对象
export default combineReducers({count,user})